<?php

namespace common\models\auth;

use Yii;
use common\models\BaseModels;

/**
 * This is the model class for table "user_admin_group".
 *
 * @property integer $id
 * @property string $name
 * @property string $remark
 * @property integer $is_valid
 * @property integer $created_at
 * @property integer $updated_at
 */
class UserAdminGroup extends BaseModels
{
    /**
     * 获取可选的公司名称
     */
    public static function getGroupName($id){
        $groupInfo   = static::findOne($id);
        $title = "-";
        if ($groupInfo) {
            $title = $groupInfo->name;
        }
        return $title;
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'user_admin_group';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'created_at', 'updated_at'], 'required'],
            [['is_valid', 'created_at', 'updated_at'], 'integer'],
            [['name'], 'string', 'max' => 32],
            [['remark'], 'string', 'max' => 512],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app_table', 'ID'),
            'name'   => Yii::t('app_table', 'admin group name'),
            'remark' => Yii::t('app_table', 'remark'),
            'is_valid'   => Yii::t('app_table', 'isvalid'),
            'created_at' => Yii::t('app_table', 'created_at'),
            'updated_at' => Yii::t('app_table', 'updated_at'),
        ];
    }
}
